/*************************************************************************
 *
 *  Copyright (C) 2013 Florian Dang <florian.coin@gmail.com>
 *
 *  This file is part of NatusVerse.
 *
 *  NatusVerse is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  NatusVerse is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with NatusVerse.  If not, see <http://www.gnu.org/licenses/>.
 *
 *************************************************************************/

#include "life/life.h"
#include "perfs.h"

#include <stdio.h>
#include <cassert>

using graphics::Graphics;

namespace life
{
void Life::GameOfLife(const int& num_col, const int& num_line)
{
	win().InitGraphics(); // Graphical window

	Automaton grid(num_col, num_line);

	grid.Initialize(win().GetW(), win().GetH());
	set_automaton(grid);


	double start = perfs::my_gettimeofday();
	Display();
/*
	// for iteration
	for (int i = 0; i < 80; i ++)
	{
		//printf("Iteration: %d\r", i);

//		automaton_.Print();

		win().PrintScreen();
		automaton_.CheckGrid(win());
	}

	double end = perfs::my_gettimeofday();
	printf(" (£) [Game Of Life] %f s\n", end - start);

*/
	win_.WaitEscape();
}

void Life::Display() const
{
	//typedef Graphics::t_point t_point;

	automaton_.Display(win_);
}
} // end namespace life
